package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/to/login")
public class ToLoginServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Map<String, String> map = GetSetCookie.get(req);
        System.out.println("list11:"+GetSetCookie.get(req));
        if (map == null || map.size() <= 0) {
            resp.sendRedirect(getServletContext().getContextPath() + "/login.jsp");
        } else {
            // 跳转到/WEB-IN/employ/employee
            req.getRequestDispatcher("/WEB-INF/employ/employee.jsp").forward(req, resp);
        }
        // if (map != null || map.size() > 0) {
        //     // 跳转到/WEB-IN/employ/employee
        //     req.getRequestDispatcher("/WEB-INF/employ/employee.jsp").forward(req, resp);
        // }
        // Cookie[] cookies = req.getCookies();
        // if (cookies.length > 0) {
        //     //跳转到/WEB-IN/employ/employee
        //     req.getRequestDispatcher("/WEB-INF/employ/employee.jsp").forward(req, resp);
        // } else {
        //     resp.sendRedirect(getServletContext().getContextPath()+"/login.jsp");
        // }
    }
}
